/* Endless Code Copyright (C) 2009 Jingul,Kim
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>
 */
package ec.gfx;

import java.nio.Buffer;
import java.nio.ByteBuffer;
import java.nio.IntBuffer;

/**
 * @since 2009
 * @version 1.0
 * @author <a href="mailto:jingul.kim@gmail.com">Jingul,Kim</a>
 */
public class GL {
	public static final int GL_MODELVIEW = 0x1700;
	public static final int GL_PROJECTION = 0x1701;

	public static final int GL_RENDER = 0x1C00;
	public static final int GL_FEEDBACK = 0x1C01;
	public static final int GL_SELECT = 0x1C02;

	public static final int GL_VIEWPORT = 0x0BA2;

	public static final int GL_MODELVIEW_MATRIX = 0x0BA6;
	public static final int GL_PROJECTION_MATRIX = 0x0BA7;

	/* Primitives */
	public static final int GL_POINTS = 0x0000;
	public static final int GL_LINES = 0x0001;
	public static final int GL_LINE_LOOP = 0x0002;
	public static final int GL_LINE_STRIP = 0x0003;
	public static final int GL_TRIANGLES = 0x0004;
	public static final int GL_TRIANGLE_STRIP = 0x0005;
	public static final int GL_TRIANGLE_FAN = 0x0006;
	public static final int GL_QUADS = 0x0007;
	public static final int GL_QUAD_STRIP = 0x0008;
	public static final int GL_POLYGON = 0x0009;

	/* Data Types */
	public static final int GL_BYTE = 0x1400;
	public static final int GL_UNSIGNED_BYTE = 0x1401;
	public static final int GL_SHORT = 0x1402;
	public static final int GL_UNSIGNED_SHORT = 0x1403;
	public static final int GL_INT = 0x1404;
	public static final int GL_UNSIGNED_INT = 0x1405;
	public static final int GL_FLOAT = 0x1406;
	public static final int GL_DOUBLE = 0x140A;

	/**/
	public static final int GL_RED = 0x1903;
	public static final int GL_GREEN = 0x1904;
	public static final int GL_BLUE = 0x1905;
	public static final int GL_ALPHA = 0x1906;
	public static final int GL_LUMINANCE = 0x1909;
	public static final int GL_LUMINANCE_ALPHA = 0x190A;

	public static final int GL_RGB = 0x1907;
	public static final int GL_RGBA = 0x1908;

	/* texture */
	public static final int GL_TEXTURE_2D = 0x0DE1;

	public static final int GL_TEXTURE_MAG_FILTER = 0x2800;
	public static final int GL_TEXTURE_MIN_FILTER = 0x2801;

	/**/
	public static final int GL_LINEAR = 0x2601;

	/* Display Lists */
	public static final int GL_COMPILE = 0x1300;
	public static final int GL_COMPILE_AND_EXECUTE = 0x1301;

	/* Blending */
	public static final int GL_BLEND = 0x0BE2;
	public static final int GL_BLEND_SRC = 0x0BE1;
	public static final int GL_BLEND_DST = 0x0BE0;
	public static final int GL_ZERO = 0x0;
	public static final int GL_ONE = 0x1;
	public static final int GL_SRC_COLOR = 0x0300;
	public static final int GL_ONE_MINUS_SRC_COLOR = 0x0301;
	public static final int GL_SRC_ALPHA = 0x0302;
	public static final int GL_ONE_MINUS_SRC_ALPHA = 0x0303;
	public static final int GL_DST_ALPHA = 0x0304;
	public static final int GL_ONE_MINUS_DST_ALPHA = 0x0305;
	public static final int GL_DST_COLOR = 0x0306;
	public static final int GL_ONE_MINUS_DST_COLOR = 0x0307;
	public static final int GL_SRC_ALPHA_SATURATE = 0x0308;
	public static final int GL_CONSTANT_COLOR = 0x8001;
	public static final int GL_ONE_MINUS_CONSTANT_COLOR = 0x8002;
	public static final int GL_CONSTANT_ALPHA = 0x8003;
	public static final int GL_ONE_MINUS_CONSTANT_ALPHA = 0x8004;

	/* glPush/PopAttrib bits */
	public static final int GL_CURRENT_BIT = 0x00000001;
	public static final int GL_POINT_BIT = 0x00000002;
	public static final int GL_LINE_BIT = 0x00000004;
	public static final int GL_POLYGON_BIT = 0x00000008;
	public static final int GL_POLYGON_STIPPLE_BIT = 0x00000010;
	public static final int GL_PIXEL_MODE_BIT = 0x00000020;
	public static final int GL_LIGHTING_BIT = 0x00000040;
	public static final int GL_FOG_BIT = 0x00000080;
	public static final int GL_DEPTH_BUFFER_BIT = 0x00000100;
	public static final int GL_ACCUM_BUFFER_BIT = 0x00000200;
	public static final int GL_STENCIL_BUFFER_BIT = 0x00000400;
	public static final int GL_VIEWPORT_BIT = 0x00000800;
	public static final int GL_TRANSFORM_BIT = 0x00001000;
	public static final int GL_ENABLE_BIT = 0x00002000;
	public static final int GL_COLOR_BUFFER_BIT = 0x00004000;
	public static final int GL_HINT_BIT = 0x00008000;
	public static final int GL_EVAL_BIT = 0x00010000;
	public static final int GL_LIST_BIT = 0x00020000;
	public static final int GL_TEXTURE_BIT = 0x00040000;
	public static final int GL_SCISSOR_BIT = 0x00080000;
	public static final int GL_ALL_ATTRIB_BITS = 0x000FFFFF;

	/* Depth buffer */
	public static final int GL_NEVER = 0x0200;
	public static final int GL_LESS = 0x0201;
	public static final int GL_EQUAL = 0x0202;
	public static final int GL_LEQUAL = 0x0203;
	public static final int GL_GREATER = 0x0204;
	public static final int GL_NOTEQUAL = 0x0205;
	public static final int GL_GEQUAL = 0x0206;
	public static final int GL_ALWAYS = 0x0207;
	public static final int GL_DEPTH_TEST = 0x0B71;
	public static final int GL_DEPTH_BITS = 0x0D56;
	public static final int GL_DEPTH_CLEAR_VALUE = 0x0B73;
	public static final int GL_DEPTH_FUNC = 0x0B74;
	public static final int GL_DEPTH_RANGE = 0x0B70;
	public static final int GL_DEPTH_WRITEMASK = 0x0B72;
	public static final int GL_DEPTH_COMPONENT = 0x1902;

	/*
	 * Stencil
	 */
	public static final int GL_STENCIL_TEST = 0x0B90;
	public static final int GL_STENCIL_WRITEMASK = 0x0B98;
	public static final int GL_STENCIL_BITS = 0x0D57;
	public static final int GL_STENCIL_FUNC = 0x0B92;
	public static final int GL_STENCIL_VALUE_MASK = 0x0B93;
	public static final int GL_STENCIL_REF = 0x0B97;
	public static final int GL_STENCIL_FAIL = 0x0B94;
	public static final int GL_STENCIL_PASS_DEPTH_PASS = 0x0B96;
	public static final int GL_STENCIL_PASS_DEPTH_FAIL = 0x0B95;
	public static final int GL_STENCIL_CLEAR_VALUE = 0x0B91;
	public static final int GL_STENCIL_INDEX = 0x1901;
	public static final int GL_KEEP = 0x1E00;
	public static final int GL_REPLACE = 0x1E01;
	public static final int GL_INCR = 0x1E02;
	public static final int GL_DECR = 0x1E03;

	public static native void pointSize(float size);

	public static native void blendFunc(int sfactor, int dfactor);

	public static native void pushAttrib(int mask);

	public static native void pushMatrix();

	public static native void popAttrib();

	public static native void popMatrix();

	public static native void multiMatrix(float[] array);

	public static native void loadIdentity();

	public static native void matrixMode(int flag);

	public static native int renderMode(int flag);

	public static native void clear(int flag);

	public static native void clearColor(float r, float g, float b, float a);

	public static native void translatef(float x, float y, float z);

	public static native void scalef(float x, float y, float z);

	public static native void rectf(float x, float y, float w, float h);

	public static native void initNames();

	public static native void loadName(int i);

	public static native void pushName(int i);

	public static native void popName();

	public static native void getFloatv(int flag, float[] array);

	public static native void getIntegerv(int flag, int[] array);

	public static native void viewport(int x, int y, int w, int h);

	public static native void ortho(double left, double right, double bottom,
			double top, double near, double far);

	public static native void color3f(float r, float g, float b);

	public static native void selectBuffer(int size, IntBuffer buffer);

	public static native void begin(int flag);

	public static native void end();

	public static native void vertex2f(float x, float y);

	public static native void vertex3f(float x, float y, float z);

	public static native void lineWidth(float w);

	public static native void rasterPos2i(int x, int y);

	public static native void drawPixels(int w, int h, int format, int type,
			Buffer buffer);

	public static native void bitmap(int w, int h, float x, float y, float mx,
			float my, ByteBuffer bitmap);

	public static native void genTextures(int n, IntBuffer textures);

	public static native void deleteTextures(int n, IntBuffer textures);

	public static native void bindTexture(int target, int texture);

	public static native void texParameteri(int target, int pname, int param);

	public static native void texImage2D(int target, int level, int inFormat,
			int w, int h, int border, int format, int type, Buffer data);

	public static native void texCoord2f(float s, float t);

	public static native void enable(int cap);

	public static native void disable(int cap);

	/*
	 * Display List
	 */
	public static native int genLists(int size);

	public static native void deleteLists(int list, int range);

	public static native void newList(int list, int mode);

	public static native void endList();

	public static native void callList(int list);

	public static native void callLists(int n, int type, Buffer lists);

	/* stencil function */
	public static native void clearStencil(int s);

	public static native void stencilFunc(int func, int ref, int mask);

	public static native void stencilOp(int fail, int zfail, int zpass);
}
